package com.zwj.batch.validators;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.util.StringUtils;

/**
 * batch 入参自定义校验器
 *
 * @author 张文接
 * @version 1.0
 * @createTime 2023-05-22 20:01:00
 */
public class NameParamValidator implements JobParametersValidator {
    @Override
    public void validate(JobParameters jobParameters) throws JobParametersInvalidException {
        String name = jobParameters.getString("name");
        if (!StringUtils.hasText(name)) {
            throw new JobParametersInvalidException("name 参数不能为空 或者 null");
        }
    }
}
